package com.amigo.online.consumer.search.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.amigo.online.common.base.controller.BaseConsumerController;
import com.amigo.online.common.core.response.Response;
import com.amigo.online.common.param.dto.query.MerchantGoodsDto;
import com.amigo.online.common.param.dto.query.Searchparam;
import com.amigo.online.consumer.search.service.SearchSevice;


@RestController
@RequestMapping(value = "/search", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class SearchController extends BaseConsumerController{
	@Autowired
	SearchSevice searchSevice;
	
	@PostMapping(value = "/searchResult")
	public ResponseEntity<Response> getSearchResult(HttpServletRequest request) {
		Searchparam dto = (Searchparam) getDto(request,Searchparam.class);
	    return searchSevice.getSearchResult(dto);
	}
	
	@GetMapping(value = "/getHotWord")
  	public ResponseEntity<Response> getHotWord() {
		 return searchSevice.getHotWord();
  	}
	@PostMapping(value = "/merchant")
	public ResponseEntity<Response> merchantSearch(@RequestBody Searchparam searchparam) {
		return searchSevice.merchantSearch(searchparam);
	}
	
	@PostMapping(value = "/merchantGoods")
	public ResponseEntity<Response> merchantGoods(@RequestBody MerchantGoodsDto searchparam) {
		return searchSevice.merchantGoodsSearch(searchparam);
	}
	
	
}
